package com.kaishengit.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.kaishengit.pojo.Goal;
import com.kaishengit.pojo.Project;
import com.kaishengit.pojo.Task;
import com.kaishengit.pojo.User;

@Repository
@SuppressWarnings("unchecked")
public class TaskDao extends BaseDao<Task,Integer>{


	public List<Task> findById(User user,Project project) {
		Query query = getSession().createQuery("from Task where user=:user and goal.project=:project order by createtime desc");
		query.setParameter("user", user);
		query.setParameter("project", project);
		return query.list();
	}

	public List<Task> findByGoalId(Goal goal) {
		Query query = getSession().createQuery("from Task where goal=:goal order by createtime desc");
		query.setParameter("goal", goal);
		return query.list();
	}
	

}
